﻿@{Layout = "~/Views/Shared/_Layout.cshtml";}
<h1>Your Current Schedule</h1>
<div id="Schedule"></div>
<script type="text/javascript">
    var IDs = "";
    function AddSchedule(ID) {
        if (ID == null || ID == "undefined") return;
        if (IDs.indexOf(ID) == -1) {
            if (IDs == "") IDs = ID + "";
            else IDs += "," + ID;
            setCookie("schedule", IDs);
            ReloadSchedule();
        }
    }
    function RemoveSchedule(ID) {
        if (IDs.indexOf(ID) != -1) {
            if (IDs.indexOf("," + ID) != -1)
                IDs = IDs.replace("," + ID.toString(), "");
            else if (IDs.indexOf(ID + ",") != -1)
                IDs = IDs.replace(ID + ",", "");
            else if (IDs.indexOf(ID) != -1)
                IDs = IDs.replace(ID, "");
            setCookie("schedule", IDs);
            ReloadSchedule();
        }
    }
    function LoadSchedules() {
        IDs = getCookie("schedule");
        if (IDs == null) IDs = "";
    }
    function ReloadSchedule()
    {
        $.ajax({
            method: "get", 
            url: "/Home/PersonalSchedule/" + IDs,
            success: function(result)
            {
                $("#Schedule").html(result);
            }
        });
    }
    LoadSchedules();
    ReloadSchedule();
</script>

@if(Scheduling.Models.Helpers.UserHelper.IsUserAuthenticated()) { 
    
}